#ifndef PATIENTDELEGATE_H
#define PATIENTDELEGATE_H

#include <QWidget>
#include <QStyledItemDelegate>
#include <QPixmap>
#include <map>
//委托类



class PatientDelegate:public QStyledItemDelegate
{
    Q_OBJECT
public:
    PatientDelegate(QObject* parent=nullptr);

    //重新实现绘制函数
    void paint(QPainter *painter, const QStyleOptionViewItem &option, const QModelIndex &index) const override;

    //在delegate中过滤事件处理
    bool editorEvent(QEvent *event, QAbstractItemModel *model, const QStyleOptionViewItem &option, const QModelIndex &index) override;

private:
    //加载图标资源
    void LoadIcon();

signals:
    //两个信号
    //编辑用户数据按钮
    void On_EditPersonData_Btn(int row)const;

    //删除用户按钮
    void On_DeletePerson_Btn(int row)const;

private:

    ///@brief 是否悬浮在btn上
    mutable int hoveredButton = -1;
    ///@brief 一个map记录按钮index和对应的状态
    mutable std::map<QPersistentModelIndex,int> m_buttonsStateMap;

    QPixmap m_profile_man;
    QPixmap m_profile_female;
    QPixmap m_profile_other;

    //两个按钮
    QPixmap edit_default,edit_clicked;
    QPixmap delete_default,delete_clicked;
};

#endif // PATIENTDELEGATE_H
